﻿<%@ Page Title="" Language="C#" MasterPageFile="~/SiteJN.Master" AutoEventWireup="true" CodeBehind="index.aspx.cs" Inherits="jnagr.Web.plantinfo.index" %>

<%@ Register Src="~/Controls/checkright.ascx" TagPrefix="uc1" TagName="checkright" %>
<%@ Register Src="~/Controls/copyright.ascx" TagPrefix="uc1" TagName="copyright" %>
<asp:Content ID="Content1" ContentPlaceHolderID="head" runat="server">
    <script type="text/javascript">
        var h;
        $(function () {
            h = $(window).height() - 210;
            $('.mycon').height(h - 50);
            $('.myh').height(h - 60);
            InitTree();
            $("#tab").tabs({
                onSelect: function (title, index) {
                    if (index == '0') {
                        InitTree();
                    }
                    else if (index == '1') {
                        pettree();
                    }
                }
            });
        });
        function InitTree() {
            $('#p').panel({
                height: h - 60,
                title: '植物信息'

            });
            $('#tt').tree({
                url: 'GetPlant.ashx', //请求数据的页面               

                lines: true,
                method: 'post',
                queryParams: { "action": "query" },
                formatter: function (node) {
                    return node.bm + " " + node.text;
                }
            });
            $('#myp').panel({
                height: h - 60,
                title: '本地植物信息'

            });
            $('#mytt').tree({
                url: 'GetPlant.ashx', //请求数据的页面               

                lines: true,
                method: 'post',
                queryParams: { "action": "querymy" },
                formatter: function (node) {
                    return node.bm + " " + node.text;
                }
            });

        }
        function pettree() {
            $('#ph').panel({
                height: h - 60,
                title: '有害生物信息'

            });
            $('#tth').tree({
                url: '../harmfulinfo/GetHarm.ashx', //请求数据的页面               

                lines: true,
                method: 'post',
                queryParams: { "action": "query" },
                formatter: function (node) {
                    return node.bm + " " + node.text;
                }
            });
            $('#myph').panel({
                height: h - 60,
                title: '本地有害生物信息'

            });
            $('#mytth').tree({
                url: '../harmfulinfo/GetHarm.ashx', //请求数据的页面               

                lines: true,
                method: 'post',
                queryParams: { "action": "querymy" },
                formatter: function (node) {
                    return node.bm + " " + node.text;
                }
            });
        }
        function newNode() {
            $('#fm').form('clear');
            var node = $('#tt').tree('getSelected');
            if (node != null) {
                $('#parentid').val(node.id);
                $('#fm').form('submit', {
                    url: "GetPlant.ashx?action=addmynode&pid=" + node.id,
                    success: function (result) {
                        if (result.indexOf("T") == 0) {
                            $('#dlg').dialog('close');
                            $.messager.alert("提示", "恭喜您，信息添加成功", "info");
                            $('#mytt').tree('reload');
                        }
                        else if ((result.indexOf("F") == 0)) {
                            $.messager.alert("提示", "添加失败，请重新操作！", "info");
                            return;
                        }
                        else if ((result.indexOf("L") == 0)) {
                            $.messager.alert("提示", "长时间没有操作，请重新登录！", "info");
                            top.location = '/index.aspx';
                            return;
                        }
                    }
                });
            }
            else {
                $.messager.alert("提示", "请选择要设置的数据！", "info");

            }

        }
        function removeUser() {
            var row = $('#mytt').tree('getSelected');
            if (row == null) {
                $.messager.alert("提示", "请选择要删除的数据！", "info");
            }
            if (row) {
                $.messager.confirm('提示', '你确定要删除这条信息吗？', function (r) {
                    if (r) {
                        $('#fm').form('submit', {
                            url: 'GetPlant.ashx?mpid=' + row.id + "&action=deletemy",
                            onSubmit: function () {
                            },
                            success: function (result) {
                                if (result.indexOf("T") == 0) {
                                    $.messager.alert("提示", "恭喜您，信息删除成功！", "info");
                                    $('#mytt').tree('reload');
                                }
                                else {
                                    $.messager.alert("提示", "删除失败，请重新操作！", "info");
                                    return;
                                }
                            }
                        });
                    }
                })

            }
        }
        function newNodeh() {
            $('#fmh').form('clear');
            var node = $('#tth').tree('getSelected');
            if (node != null) {
                $('#parentidh').val(node.id);
                $('#fmh').form('submit', {
                    url: "../harmfulinfo/GetHarm.ashx?action=addmynode&hid=" + node.id,
                    success: function (result) {
                        if (result.indexOf("T") == 0) {
                            $('#dlgh').dialog('close');
                            $.messager.alert("提示", "恭喜您，信息添加成功", "info");
                            $('#mytth').tree('reload');
                        }
                        else if ((result.indexOf("F") == 0)) {
                            $.messager.alert("提示", "添加失败，请重新操作！", "info");
                            return;
                        }
                        else if ((result.indexOf("L") == 0)) {
                            $.messager.alert("提示", "长时间没有操作，请重新登录！", "info");
                            top.location = '/index.aspx';
                            return;
                        }
                    }
                });
            }
            else {
                $.messager.alert("提示", "请选择要设置的数据！", "info");

            }

        }
        function removeUserh() {
            var row = $('#mytth').tree('getSelected');
            if (row == null) {
                $.messager.alert("提示", "请选择要删除的数据！", "info");
            }
            if (row) {
                $.messager.confirm('提示', '你确定要删除这条信息吗？', function (r) {
                    if (r) {
                        $('#fmh').form('submit', {
                            url: '../harmfulinfo/GetHarm.ashx?mhid=' + row.id + "&action=deletemy",
                            onSubmit: function () {
                            },
                            success: function (result) {
                                if (result.indexOf("T") == 0) {
                                    $.messager.alert("提示", "恭喜您，信息删除成功！", "info");
                                    $('#mytth').tree('reload');
                                }
                                else {
                                    $.messager.alert("提示", "删除失败，请重新操作！", "info");
                                    return;
                                }
                            }
                        });
                    }
                })

            }
        }

        function saveUser() {
            var test = document.getElementById("test").value;
            var f = $('#fmrz');
            f.form('submit', {
                url: "GetCate.ashx?action=" + test,
                onSubmit: function () {
                    return $(this).form('validate');
                },
                success: function (result) {
                    if (result.indexOf("T") == 0) {
                        $('#dlg').dialog('close');
                        $.messager.alert("提示", "恭喜您，信息添加成功", "info");
                        $('#tt').datagrid('reload');
                    }
                    else if ((result.indexOf("F") == 0)) {
                        $.messager.alert("提示", "添加失败，请重新操作！", "info");
                        return;
                    }
                    else if ((result.indexOf("L") == 0)) {
                        $.messager.alert("提示", "长时间没有操作，请重新登录！", "info");
                        top.location = '/index.aspx';
                        return;
                    }
                }
            });
        }
        function InitGird() {
            $('#mtgrid').datagrid({
                title: '作物', //表格标题
                url: 'GetInfo.ashx', //请求数据的页面
                sortName: 'infotime', //排序字段
                idField: 'iid', //标识字段,主键
                iconCls: '', //标题左边的图标
                width: '100%', //宽度
                height: '100%',
                nowrap: false, //是否换行，True 就会把数据显示在一行里
                striped: true, //True 奇偶行使用不同背景色
                collapsible: false, //可折叠
                sortOrder: 'desc', //排序类型
                remoteSort: true, //定义是否从服务器给数据排序
                fitColumns: true,
                singleSelect: false,
                method: 'post',
                columns: [[//
                    { field: 'ckb', checkbox: true },
                    { title: '标题', field: 'title', width: 150, sortable: true },
                    {
                        title: '发送时间', field: 'infotime', width: 200, formatter: function (value, row, index) {
                            if (value != "") {

                                if (value.indexOf("-") != -1)
                                    value = value.replace(/-/g, "/")
                                return new Date(value).pattern("yyyy年M月d日");
                            }
                        }
                    },
                    {
                        title: '操作', field: 'iid', width: 80, formatter: function (value, row, index) {

                            return '<a style="color:red" href="javascript:" onclick="$(this).parent().click();showData(\'mtgrid\');return false;">详细信息</a>';
                        }
                    }
                ]
                ],
                toolbar: "#tab_toolbars",
                queryParams: { "action": "query", "StartTime": $("#StartTime").datebox("getValue"), "EndTime": $("#EndTime").datebox("getValue") },
                pagination: true, //是否开启分页
                pageNumber: 1, //默认索引页
                pageSize: 20, //默认一页数据条数
                rownumbers: true,
                onLoadSuccess: function (data) {
                }
            });
        }
    </script>
    <style type="text/css">
        html, body {
            height: 100%;
        }

        .fitem label {
            width: 100px;
        }
    </style>
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" runat="server">
    <div id="mainDiv">
        <uc1:checkright runat="server" ID="checkright" />
        <div id="menueDiv">
            <div id="menuem">
                <div class="menuecur">
                    <div class="menueparentDiv" title="本地植物" etitle="RT" style="height: 60px; width: 120px; line-height: 60px; text-align: left; font-size: 20px;">
                        本地植物
                    </div>
                </div>
            </div>
        </div>
        <div>
            <div id="contentDiv">

                <div id="tab" class="easyui-tabs">
                    <div title="本地植物" style="padding: 1px;">
                        <div class="easyui-layout mycon" style="width: 100%; height: 100%;">
                            <div region="west" split="true" class="myh" style="width: 280px; overflow: auto" id="west">
                                <div id="p" class="easyui-panel" data-options="iconCls:'icon-save',tools:'#tab_toolbar'" style="overflow: auto;">
                                    <ul id="tt"></ul>
                                </div>

                            </div>
                            <div region="center" class="myh" style="background: #eee; overflow: auto">
                                <div id="myp" class="easyui-panel" data-options="iconCls:'icon-save',tools:'#tab_toolbar2'" style="overflow: auto;">
                                    <ul id="mytt"></ul>
                                </div>

                            </div>



                        </div>

                    </div>
                    <div title="本地有害生物" style="overflow: auto; padding: 1px;">
                        <div class="easyui-layout mycon" style="width: 100%; height: 100%;">
                            <div region="west" split="true" class="myh" style="width: 300px; overflow: auto">
                                <div id="ph" class="easyui-panel" data-options="iconCls:'icon-save',tools:'#tab_toolbarh'" style="overflow: auto;">
                                    <ul id="tth"></ul>
                                </div>

                            </div>
                            <div region="center" class="myh" style="background: #eee; overflow: auto">
                                <div id="myph" class="easyui-panel" data-options="iconCls:'icon-save',tools:'#tab_toolbar2h'" style="overflow: auto;">
                                    <ul id="mytth"></ul>
                                </div>

                            </div>



                        </div>


                    </div>

                </div>

            </div>
            <uc1:copyright runat="server" ID="copyright" />
            <div id="tab_toolbar">
                <a href="#" onclick="newNode();" id="a_add" class="icon-add" style="margin-right: 10px"></a>

            </div>
            <div id="tab_toolbar2">
                <a href="#" onclick="removeUser();return false;" id="a2" class="icon-cancel" style="margin-right: 10px"></a>
            </div>
            <div id="dlg" class="easyui-dialog" style="width: 350px; height: auto; padding: 10px 20px"
                data-options="closed:true,shadow:false">
                <form id="fm" method="post">
                </form>
            </div>
            <div id="tab_toolbarh">
                <a href="#" onclick="newNodeh();" id="a_addh" class="icon-add" style="margin-right: 10px"></a>

            </div>
            <div id="tab_toolbar2h">
                <a href="#" onclick="removeUserh();return false;" id="a1" class="icon-cancel" style="margin-right: 10px"></a>
            </div>
            <div id="dlgh" class="easyui-dialog" style="width: 350px; height: auto; padding: 10px 20px"
                data-options="closed:true,shadow:false">
                <form id="fmh" method="post">
                </form>
            </div>
        </div>
    </div>

</asp:Content>
